<template>
	<div>
		<div class="bg-white p-[40px]">
			<el-row>
				<el-col :span="6">
					<div class="main-color v-flex-col">
						<span>订单汇率：</span>
						<el-input v-model="setInfo.order_exchange_rate" type="number" min="0" class="flex-1 mt-[10px]" placeholder="请输入"></el-input>
					</div>
				</el-col>
			</el-row>
			<el-row class="mt-[30px]">
				<el-col :span="6">
					<div class="main-color v-flex-col">
						<span>货运汇率：</span>
						<el-input v-model="setInfo.freight_exchange_rate" type="number" min="0" class="flex-1 mt-[10px]" placeholder="请输入"></el-input>
					</div>
				</el-col>
			</el-row>
			<el-row class="mt-[30px]">
				<el-col :span="6">
					<div class="main-color v-flex-col">
						<span>供应商汇率：</span>
						<el-input v-model="setInfo.supplier_exchange_rate" type="number" min="0" class="flex-1 mt-[10px]" placeholder="请输入"></el-input>
					</div>
				</el-col>
			</el-row>
		</div>
		<el-row class="mt-[30px]">
			<el-button class="w-[100px] h-[36px]" color="#0054A6" type="primary" @click="clickSave()">保存</el-button>
		</el-row>
	</div>
</template>

<script lang="ts" setup>
	import { basicGet , basicSet } from '@/api/basicSettings'
	import feedback from '@/utils/feedback'
	const setInfo = ref({})
	// 获取基础配置
	const getSet = async (value:any) => {
		 await basicGet().then(res=>{
				setInfo.value = res
			 console.log(setInfo)
		 })
	}
	getSet()
	// 保存
	const clickSave = async ()=>{
		if(Number(setInfo.value.order_exchange_rate)<0){
			return feedback.msgError('请输入大于0的订单汇率')
		}
		if(Number(setInfo.value.freight_exchange_rate)<0){
			return feedback.msgError('请输入大于0的货运汇率')
		}
		if(Number(setInfo.value.supplier_exchange_rate)<0){
			return feedback.msgError('请输入大于0的供应商汇率')
		}
		await basicSet(setInfo.value).then(res=>{
			feedback.msgSuccess('操作成功')
			getSet()
		})
	}
</script>

<style>
</style>